#include "Misc.h"
#include "Game.h"
#include "ObjectDatabase.h"
#include "Renderer.h"
#include "Util.h"

Misc::Misc(MiscType type) : Item(GT_IT_MISC) {
	m_types[TH_MISC_TYPE] = type;
	const MiscInfo& info = g_objectDatabase->getMiscInfo(type);
	m_weight = info.weight;
	m_stackable = true;
}

Misc::Misc(std::ifstream& file) : Item(GT_IT_MISC, file) {
	int* tokens = Util::intSplit(file);
	m_types[TH_MISC_TYPE] = tokens[0];
	const MiscInfo& info = g_objectDatabase->getMiscInfo(MiscType(tokens[0]));
	m_weight = info.weight;
	m_stackable = true;
	delete[] tokens;
}

Misc::~Misc() {
}

void Misc::save(std::ofstream& file) const {
	file << getType(TH_GENERIC_TYPE) << "\n";
	Item::save(file);
	file << getType(TH_MISC_TYPE) << "\n";
}

void Misc::render(float x, float y) {
	g_renderer->render(*this, x, y);
}